package com.changanw.tienchin.follow.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.changanw.tienchin.common.constant.TienChinConstants;
import com.changanw.tienchin.common.core.domain.AjaxResult;
import com.changanw.tienchin.follow.domain.FollowRecord;
import com.changanw.tienchin.follow.mapper.FollowRecordMapper;
import com.changanw.tienchin.follow.service.IFollowRecordService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author changanw
 * @since 2023-11-25
 */
@Service
public class FollowRecordServiceImpl extends ServiceImpl<FollowRecordMapper, FollowRecord> implements IFollowRecordService {

  @Override
  public AjaxResult getRecordByClueId(Integer clueId) {
    QueryWrapper<FollowRecord> qu = new QueryWrapper<>();
    qu.lambda().eq(FollowRecord::getType, TienChinConstants.CLUE_TYPE).eq(FollowRecord::getAssign,clueId);
    return AjaxResult.success(list(qu));
  }

  @Override
  public AjaxResult getRecordByBusinessId(Integer businessId) {
    QueryWrapper<FollowRecord> qu = new QueryWrapper<>();
    qu.lambda().eq(FollowRecord::getType, TienChinConstants.BUSINESS_TYPE)
            .eq(FollowRecord::getAssign,businessId).orderByDesc(FollowRecord::getCreateTime);
    return AjaxResult.success(list(qu));
  }
}
